<template>
	<view>
		<u-navbar title="优惠券" :autoBack="true" placeholder>
		</u-navbar>
		<scroll-view :scroll-y="true" refresher-enabled="true" :refresher-triggered="triggered"
			@refresherrefresh="onRefresh" @scrolltolower="onLower"
			:style="{height: scrollViewHeight}">
			<view style="height: 160rpx;" v-for="item in list" :key="item.id">{{item.dictName}}</view>
			<u-loadmore :status="status" />
		</scroll-view>
	</view>
</template>

<script>
	import {getOrderDetail1} from '@/api/me.js';
	export default {
		data() {
			return {
				triggered: false,
				list: [],
				pageSize: 10,
				pageNo: 1,
				total: 0,
				status: 'loadmore'
			}
		},
		computed: {
			appColor() {
				return this.appPrimaryColor
			},
			scrollViewHeight() {
				return this.scrollHeight - 44 + 'px';
			}
		},
		onLoad() {
			this.getList();
		},
		methods: {
			getList() {
				let postObj = {
					pageNo: this.pageNo,
					pageSize: this.pageSize
				}
				getOrderDetail1(postObj).then(res => {
					const {current, pages, records} = res.result;
					this.list = this.list.concat(records);
					if(current >= pages) {
						this.status = 'nomore'
					} else {
						this.pageNo ++;
						this.status = 'loading'
					}
					this.triggered = false
				})
			},
			onRefresh() {
				this.triggered = true;
				this.pageNo = 1;
				this.getList()
			},
			onLower() {
				if(this.status === 'loading') {
					this.getList();
				}
			}
		}
	}
</script>

<style>
	page {
		background-color: #f2f2f2;
	}
</style>
<style lang="scss" scoped>
</style>
